package com.five.controller.backstage;

import com.five.dao.backstage.RoomFacDao;
import com.five.entity.backstage.TRoomFacility;
import com.five.util.LayTable;
import com.five.util.Page;
import com.five.util.TransBean;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @Author: 常鹏宇
 * @Description:
 * @Date: 2020/11/12 18:56
 */

@Controller
public class RoomFacController {
    @Autowired
    private RoomFacDao roomFacDao;
    @RequestMapping("selectRoomFac")
    @ResponseBody
    public LayTable selectRoomFac(Page pageInfo,TRoomFacility tRoomFacility){
        List<Map> list = roomFacDao.selectRoomFac(pageInfo,tRoomFacility);
        int count = roomFacDao.count(tRoomFacility);
        List populate = TransBean.populate(TRoomFacility.class, list);
        LayTable layTable = new LayTable(count, populate);
        return layTable;
    }

    @RequestMapping("/delRoomFac")
    @ResponseBody
    public void delRoomFac(TRoomFacility tRoomFacility){ roomFacDao.delRoomFac(tRoomFacility); }

    @RequestMapping("addAndUpdRF")
    @ResponseBody
    public void addRoomFac(TRoomFacility tRoomFacility){
        roomFacDao.addRoomFac(tRoomFacility);
    }

    @RequestMapping("selectrid")
    @ResponseBody
    public List<Map> selectrid(){
        return roomFacDao.selectrid();
    }

    @RequestMapping("selectFname")
    @ResponseBody
    public List<Map> selectFname(){
        return roomFacDao.selectFname();
    }
}
